package com.itheima.api.treemap.demo01;

import java.util.Comparator;
import java.util.TreeMap;
import java.util.function.BiConsumer;

public class String_String {

    public static void main(String[] args) {

//        TreeMap<String, String> treeMap = new TreeMap<String, String>();
//        TreeMap<String, String> treeMap = new TreeMap<String, String>(new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o1.compareTo(o2);
//            }
//        });
        TreeMap<String, String> treeMap = new TreeMap<String, String>((key, value) -> key.compareTo(value));
        treeMap.put("蓝湛", "蓝忘机");
        treeMap.put("魏婴", "魏无羡");
        treeMap.put("温宁", "温琼林");
        treeMap.put("江澄", "江晚吟");
        treeMap.put("金凌", "金如兰");

        treeMap.forEach(new BiConsumer<String, String>() {
            @Override
            public void accept(String s, String s2) {
                System.out.println(s + "-1-" + s2);
            }
        });
        System.out.println("-----------");
        treeMap.forEach((key, value) -> System.out.println(key + "-2-" + value));
        System.out.println("------------");
        for(String key : treeMap.keySet()){
            System.out.println(key + "-3-" + treeMap.get(key));
        }

    }
}
